package com.sch.study.concurrency.baseThread;

/**
 * User: hui_stone
 * Date: 2016/2/24 0024
 * Time: 下午 15:43
 */
public class MyThread extends Thread {

    private int ticket = 10;
    @Override
    public void run() {

        for(int i = 0;i<20;i++){
            if(ticket>0){
                System.out.println(getName()+" 卖票：ticket"+this.ticket--);
            }
        }
    }


    public static void main(String[] args) {
        // 启动3个线程t1,t2,t3；每个线程各卖10张票！
        MyThread t1=new MyThread();
        MyThread t2=new MyThread();
        MyThread t3=new MyThread();
        t1.start();
        t2.start();
        t3.start();
    }
}
